{include file="common/_header-css"}
<body>
<div class="layui-fluid">
    <div class="layui-row">
        <form class="layui-form">
            <div class="layui-form-item layui-form-text">
                <label for="title" class="layui-form-label">
                    <span class="x-red">*</span>题目
                </label>
                <div class="layui-input-block">
                    <textarea placeholder="请输入题目内容" id="title" name="title" required="" lay-verify="required"
                              class="layui-textarea"></textarea>
                </div>
            </div>
            <div class="layui-form-item">
                <label for="answer" class="layui-form-label">
                    <span class="x-red">*</span>选择正确答案</label>
                <div class="layui-input-inline">
                    <select id="answer" name="answer">
                        <option value="1">正确</option>
                        <option value="2">错误</option>
                    </select>
                </div>
            </div>
            <div class="layui-form-item">
                <label for="department_name" class="layui-form-label">
                    <span class="x-red">*</span>属于部门</label>
                <div class="layui-input-inline">
                    <input type="text" id="department_name" autocomplete="off" class="layui-input" value="{$department.name}" disabled>
                </div>
                <input type="hidden" name="department_id" value="{$department.id}">
            </div>
            <div class="layui-form-item">
                <label for="sort" class="layui-form-label">
                    <span class="x-red">*</span>排序规则</label>
                <div class="layui-input-inline">
                    <input type="text" id="sort" name="sort" autocomplete="off" class="layui-input" value="10000">
                </div>
            </div>
            <input type="hidden" name="type" value="2">
            <div class="layui-form-item">
                <label for="layui-btn" class="layui-form-label"></label>
                <button id="layui-btn" class="layui-btn" lay-filter="add" lay-submit="">增加</button>
            </div>
        </form>
    </div>
</div>
{include file="common/_jQuery"}
<script>
    layui.use(['form', 'layer'],
        function() {
            $ = layui.jquery;
            var form = layui.form,
                layer = layui.layer;

            //监听提交
            form.on('submit(add)', function(data) {
                $.post('{:url(\'question_add\')}',data.field,function (res) {
                    if (res.code == 200) {
                        layer.msg(res.msg,{icon:6,time:500},function () {
                            var index = parent.layer.getFrameIndex(window.name);
                            parent.layer.close(index);
                        });
                    }else{
                        layer.msg(res.msg,{icon:5,time:500});
                    }
                });
                return false;
            });
        });
</script>
</body>

</html>